<?php 
/**
 * 回答列表
 */

namespace Admin\Controller;
use Hdphp\Library\Controller;

class AnswerController extends CommonController{

	public function index(){

		$w=isset($_GET['w']) ? intval($_GET['w']) :'';

		switch ($w) {
			// 未采纳
			case '1':
				$where= " WHERE accept=0";
				break;
			// 已采纳
			case '2':
				$where= " WHERE accept=1";
				break;
						
			default:
				$where= "";
				break;
		}

		$sql="SELECT * FROM hd_answer {$where}";
		$answer=M()->query($sql);
		$this->assign('answer',$answer);
		$this->assign('totalAnswer',count($answer));
		$this->display();
	}

	public function del(){

		$anid=intval($_GET['anid']);

		$sql="DELETE FROM hd_answer WHERE anid={$anid}";
		if( M()->exec($sql) ){
			$this->error('删除成功');
		}

	}


}

 ?>